package org.ricks.log.message;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

/**
 * @author chenwei
 * @Description:
 * @date 2023/1/916:15
 */
class MessageAnalyzerManager {
    /**
     * 1分钟
     */
    private static final int DURATION = 1;
    private final Map<String, MessageAnalyzer> caches;

    MessageAnalyzerManager() {
        this.caches = new ConcurrentHashMap<>(1024);
    }

    public MessageAnalyzer get(String key, Function<? super String, ? extends MessageAnalyzer> mappingFunction) {
        return caches.computeIfAbsent(key, mappingFunction);
    }
}
